/*定位.js*
$(function(){
    getLocation();
})*/
function getLocation() {
      var geolocation = new BMap.Geolocation();
      geolocation.getCurrentPosition(function(r){
            console.log(this.getStatus());
            if(this.getStatus() == 0){
                var geoc = new BMap.Geocoder();
                geoc.getLocation(r.point,function(rs){
                    var address = rs.addressComponents;
                    var addComp = rs.addressComponents;
                    var currentCity,currentLocation;
                    currentCity =addComp.province.slice(0,-1) + "-" + addComp.city /*+ "-" +addComp.district*/;
                    console.log(currentCity);
                    
                    if(rs.surroundingPois.length!==0){
                        currentLocation = rs.surroundingPois[0].title;
                    }else if(rs.surroundingPois.length==0){
                        if(rs.business!==''){
                            currentLocation = rs.business.split(',')[0];
                        }else if(rs.business==''){
                            currentLocation = addComp.city;
                        }
                    }
                    /*console.log(currentLocation);*/
                    var loca = currentCity + currentLocation;
                    $('#map').html(loca);
                });
            }else{
                console.log("定位失败");
            };
        },{enableHighAccuracy: true});
    }
